package com.nmgydy.beans;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;

public class ListBean {
	
	private long total;
	private List<?> data;
	private Map<String,Object> params;
	
	public ListBean(){
		this.total = 0;
		this.data = new ArrayList<Object>();
		this.params = new HashMap<String,Object>();
	}
	public ListBean(List<?> list){
		setData(list);
	}
	public ListBean(List<?> list,long total) {
		this.total = total;
		this.data = list;
	}
	public ListBean(Map<String,Object> params,List<?> list,long total) {
		this.total = total;
		this.data = list;
		this.params = params;
	}
	
	public long getTotal() {
		return total;
	}
	public List<?> getData() {
		return data;
	}
	public Map<String, Object> getParams() {
		return params;
	}
	public void setParams(Map<String, Object> params) {
		if(params != null){
			this.params = params;
		}else{
			this.params = new HashMap<String,Object>();
		}
	}
	public void setTotal(long total) {
		this.total = total;
	}
	public void setData(List<?> list) {
		if(list != null){
			this.total = list.size();
			this.data = list;
		}else{
			this.total = 0;
			this.data = new ArrayList<Object>();
		}
	}
	
	@Override
	public String toString() {
		return JSON.toJSON(this).toString();
	}
	
}
